]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
components: Allow cancelling of dialog between prompts
authorStef Walter <stefw@gnome.org>
Tue, 25 Sep 2012 19:53:36 +0000 (21:53 +0200)
committerStef Walter <stefw@gnome.org>
Thu, 9 May 2013 03:58:55 +0000 (05:58 +0200)
Some callers of the keyring prompt keep the dialog up while
processing the prompt. Allow the user to cancel the prompt
while in this state.

This is propagated to the caller, who can cancel the operation
in question when this occurs.

https://bugzilla.gnome.org/show_bug.cgi?id=682830

js/ui/components/keyring.js
src/shell-keyring-prompt.c

index ae67b5510b8672eb42bc8dc7618a83a5dc0a4972..40d06d15453c2d84352ebed34f37e25d2cb379c0 100644 (file)
@@ -25,7 +25,7 @@ const KeyringDialog = new Lang.Class({
         this.prompt = new Shell.KeyringPrompt();
         this.prompt.connect('show-password', Lang.bind(this, this._onShowPassword));
         this.prompt.connect('show-confirm', Lang.bind(this, this._onShowConfirm));
-        this.prompt.connect('hide-prompt', Lang.bind(this, this._onHidePrompt));
+        this.prompt.connect('prompt-close', Lang.bind(this, this._onHidePrompt));
 
         let mainContentBox = new St.BoxLayout({ style_class: 'prompt-dialog-main-layout',
                                                 vertical: false });
index 01eb409f8a440e0ec39383a2ed42a8946f038be0..bafcb90b4feb919bb2aaf808b63602cda65dfbcf 100644 (file)
@@ -100,7 +100,6 @@ G_DEFINE_TYPE_WITH_CODE (ShellKeyringPrompt, shell_keyring_prompt, G_TYPE_OBJECT
 enum {
   SIGNAL_SHOW_PASSWORD,
   SIGNAL_SHOW_CONFIRM,
-  SIGNAL_HIDE_PROMPT,
   SIGNAL_LAST
 };
 
@@ -258,10 +257,8 @@ shell_keyring_prompt_dispose (GObject *obj)
 {
   ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (obj);
 
-  if (self->shown) {
-    self->shown = FALSE;
-    g_signal_emit (self, signals[SIGNAL_HIDE_PROMPT], 0);
-  }
+  if (self->shown)
+    gcr_prompt_close (GCR_PROMPT (self));
 
   if (self->async_result)
     shell_keyring_prompt_cancel (self);
@@ -384,11 +381,6 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
                                                 0, 0, NULL, NULL,
                                                 g_cclosure_marshal_VOID__VOID,
                                                 G_TYPE_NONE, 0);
-
-  signals[SIGNAL_HIDE_PROMPT] =  g_signal_new ("hide-prompt", G_TYPE_FROM_CLASS (klass),
-                                               0, 0, NULL, NULL,
-                                               g_cclosure_marshal_VOID__VOID,
-                                               G_TYPE_NONE, 0);
 }
 
 static void
@@ -482,6 +474,19 @@ shell_keyring_prompt_confirm_finish (GcrPrompt    *prompt,
   return self->last_reply;
 }
 
+static void
+shell_keyring_prompt_close (GcrPrompt *prompt)
+{
+  ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (prompt);
+
+  /*
+   * We expect keyring.js to connect to this signal and do the
+   * actual work of closing the prompt.
+   */
+
+  self->shown = FALSE;
+}
+
 static void
 shell_keyring_prompt_iface (GcrPromptIface *iface)
 {
@@ -489,6 +494,7 @@ shell_keyring_prompt_iface (GcrPromptIface *iface)
   iface->prompt_password_finish = shell_keyring_prompt_password_finish;
   iface->prompt_confirm_async = shell_keyring_prompt_confirm_async;
   iface->prompt_confirm_finish = shell_keyring_prompt_confirm_finish;
+  iface->prompt_close = shell_keyring_prompt_close;
 }
 
 /**
@@ -746,9 +752,19 @@ shell_keyring_prompt_cancel (ShellKeyringPrompt *self)
   GSimpleAsyncResult *res;
 
   g_return_if_fail (SHELL_IS_KEYRING_PROMPT (self));
-  g_return_if_fail (self->mode != PROMPTING_NONE);
-  g_return_if_fail (self->async_result != NULL);
 
+  /*
+   * If cancelled while not prompting, we should just close the prompt,
+   * the user wants it to go away.
+   */
+  if (self->mode == PROMPTING_NONE)
+    {
+      if (self->shown)
+        gcr_prompt_close (GCR_PROMPT (self));
+      return;
+    }
+
+  g_return_if_fail (self->async_result != NULL);
   self->last_reply = GCR_PROMPT_REPLY_CANCEL;
 
   res = self->async_result;